
#ifndef __COID_SERVER_LOGENTMGR__HEADER_FILE__
#define __COID_SERVER_LOGENTMGR__HEADER_FILE__

#include "coid/svc/coidsvc.h"

//{client
#include "coid/svc/logstream.h"
//}client

namespace coid {

class Filter;

////////////////////////////////////////////////////////////////////////////////
///COID Log manager service
class LogEntMgr
{
    //NET_OPTIONS: direct nolog nolog_system_calls
    Filter*  _filter;             ///< log query filters
    cmd_interface* _cmdin;

public:

    LogEntMgr()
    {
        _filter = 0;
    }

    ~LogEntMgr();

    // special functions
    net_fnc_s opcd accept_connect( net_in const charstr& name, net_in const password& pwd )
    {
        account_id acid;
        acid._name = name;
        acid._pwd = pwd;
        opcd e = _cmdin->set_identity(acid,false);

        return e;
    }

    net_fnc_s opcd accept_startup_params( cmd_interface& cmd )
    {
        _cmdin = &cmd;
        return 0;
    }
    
    net_fnc_s opcd accept_connect_shared()
    {
        return ersDENIED;
    }

    // client functions
    net_fnc_d opcd read_log       ( net_inout uints& ref, net_in uints max, net_out dynarray<logstream*>& list ) const;
    net_fnc opcd add_filter     ( net_in const FILTER_ENTRY& flt );
    net_fnc opcd delete_filter  ( net_in uint obj, net_in uint fltn );
    net_fnc opcd get_filters    ( net_in uint obj, net_in uint fltn, net_out dynarray<FILTER_ENTRY>& out ) const;
    net_fnc opcd get_filter_ids ( net_in uint obj, net_in uint fltn, net_out dynarray<uint>& out ) const;

    net_fnc opcd get_log_upd    ( net_out uints* ref ) const;

    net_fnc opcd get_tree_info  ( net_out dynarray<tree_info>& out, net_out uints* ref ) const;
    net_fnc opcd get_tree_info_changes  ( net_inout uints& ref, net_out dynarray<tree_info>& out ) const;
};

} // namespace coid

#endif //__COID_SERVER_LOGENTMGR__HEADER_FILE__
